<?php
class EmptyAction extends BaseAction{
	//public function _initialize(){
	//	getCategory(array('id'=>15));
	//}

	public function index(){
		
		$this->display("category:index");
	}

	public function _empty(){
		$channels = array('sanwen','shige');//频道目录的范围;
		$channel_name = MODULE_NAME;
		$channel_name = (empty($channel_name) || !in_array($channel_name, $channels))?'sanwen':$channel_name;
		$typedir = '/'.$channel_name.'/'.ACTION_NAME;		
		$categoryinfos = getCategory(array('typedir'=>$typedir));
		$typeid = $categoryinfos['id'];
		if(is_null($typeid)) $this->error('你查找的栏目不存在'); 
		
		$this->category($typeid);
		$this->assign('title',$categoryinfos['typename'].'_'."散文吧");
		$this->assign('typedir',$categoryinfos['typedir']);
		$this->display('category:category');
	}
	
	
	protected function category($type_id = 0){
		$listRows = 20;
		
		$cateDao = D('Archives');
		if($type_id){
			$where['typeid'] = $type_id;
		}
		$order = 'arc.id desc';
		if($_GET['action']){
			if($_GET['action'] == 'elite') $where['flag'] = 'c';
			if($_GET['action'] == 'reply') $order = 'arc.replynum desc';
			
		}
		$this->assign('action',$_GET['action']);
		
		$count = $cateDao->where($where)->count();
		import('ORG.Util.Page');
		$p = new page($count,$listRows);
		$cateVo = $cateDao->table('www_archives arc')->join('www_user_info info on info.uid=arc.mid')->field('info.face,arc.*')->where($where)->limit($p->firstRow.','.$p->listRows)->order($order)->findall();
		$page = $p->show();
		$this->assign('page',$page);
		$this->assign('cateVo',$cateVo);
	}
}
?>